package thread.biz;


import thread.util.MixUtils;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

/**
 * Payment Order Service
 */
public class POrderService {
    private Map<Integer, POrder> poMap = new HashMap<>();
    private Random random = new Random();

    public POrderService() {
        for (int id = 1; id <= MixUtils.IDMAX; id++)
            poMap.put(id, POrder.builder().id(id).paymentInfo("支付订单" + id).build());
    }

    public POrder getPOrder(int id) {
        MixUtils.sleepMs(20/* + random.nextInt(800)*/); // 模拟延时 20ms
        return poMap.get(id);
    }
}
